#include "CFGConfig.h"
using namespace xml_api;

CCFGConfig* CCFGConfig::m_ptr_instance = NULL;

CCFGConfig* CCFGConfig::Instance()
{
  if(NULL == m_ptr_instance)
    m_ptr_instance = new CCFGConfig;

  return m_ptr_instance;
}

CCFGConfig::CCFGConfig(void)
{
}

CCFGConfig::~CCFGConfig(void)
{
}

bool CCFGConfig::SaveState(xml_api::Memento* m)
{
  return true;
}

bool CCFGConfig::LoadState(xml_api::Memento* m)
{
  int child_num=m->GetChildCount();
  for(int i=0; i<child_num; ++i)
  {
    Memento* child_m=m->GetChild(i);
    std::string child_name = child_m->GetName();
    if("DataSource" == child_name)
    {
      m_data_source.LoadState(child_m);
    }
    else if("BaseConfig" == child_name)
    {
      m_base_config.LoadState(child_m);
    }
    else if("CodeManager" == child_name)
    {
      m_code_manager.LoadState(child_m);
    }
    else if("MarketTime" == child_name)
    {
      m_market_time.LoadState(child_m);
    }
  }
  return true;
}
